package com.cloud.elm.mapper;

import com.cloud.elm.po.User;
import com.cloud.elm.po.dto.UserDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

	@Select("select * from user where userId=#{userId} and password=#{password}")
    User getUserByIdByPass(User user);
	
	@Select("select count(*) from user where userId=#{userId}")
    int getUserById(String userId);
	
	@Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1,2)")
    int saveUser(User user);

	@Select("select password from user where userId = #{userId}")
    String getPasswordById(String userId);

	@Update("update user set password = #{newPassword} where userId = #{userId}")
	void changePassword(String userId, String newPassword);

	@Select("select * from user where userId = #{userId}")
    User getUserInfoById(String userId);

	@Update("update user set userName = #{userName}, userImg = #{userImg} where userId = #{userId}")
    void updateInfo(UserDTO userDTO);
}
